<template>

	<view class="main">
		<u-navbar :fixed="false" title="随访计划模板库" @rightClick="rightClick" :autoBack="true"></u-navbar>
		<view class="search-bar">
			<u-search v-model="keyword" placeholder="搜索" @search="onSearch" @custom="onSearch" />
		</view>




		<z-paging ref="paging" v-model="followTemplateListData" @query="queryList" usePageScroll>
			<view class=" column_c">
				<view class="card-content" v-for="(item, index) in followTemplateListData" :key="index" @click="toUrlInfo(item.id)">
					<view class="row_a_c space-between">
						<view>
							<text class="clinic">{{item.name}}</text>
							<view class="time">{{item.store.name}}</view>
						</view>
						<view class="status  center">{{item.id}}</view>
					</view>
				</view>
			</view>
		</z-paging>



	</view>

</template>

<script>
	import api_follow from '@/api/follow.js';
	import ZPMixin from '@/uni_modules/z-paging/components/z-paging/js/z-paging-mixin';

	export default {
		mixins: [ZPMixin],
		async onShow() {
			this.access_token = uni.getStorageSync('access_token');
			if (!this.access_token) {
				uni.navigateTo({
					url: '/pages/auth/login'
				});
			} else {
				// this.followTemplateListFuc(); //随访模板列表
			}
		},

		async onLoad(option) {
			this.order = option.id;
			console.log('order', this.order);
		},
		data() {
			return {
				order: null,
				access_token: null,
				keyword: null,
				followTemplateListData: [],
			};
		},
		methods: {
			onSearch(value) {
				// this.followTemplateListFuc();
				this.$refs.paging.reload();
			},

			toUrlInfo(id) {
				if (this.order) {
					uni.navigateTo({
						url: '/pages/followup/add-followup?id=' + id + '&order=' + this.order
					});
				} else {
					uni.navigateTo({
						url: '/pages/followup/template-info?id=' + id
					});
				}

			},




			async queryList(pageNo, pageSize) {

				var per = {
					no_page: pageNo,
					page_size: pageSize,
				}
				if (this.keyword) {
					per.keyword = this.keyword
				}
				const res = await api_follow.followTemplateList(per);
				if (res.code == 1) {
					this.$refs.paging.complete(res.data.list);
				} else {
					this.$refs.paging.complete(false);
				}

			},

			//随访模板列表
			// async followTemplateListFuc() {
			// 	var per = {
			// 		no_page: 1,
			// 		page_size: 10,
			// 	}
			// 	if (this.keyword) {
			// 		per.keyword = this.keyword
			// 	}
			// 	const res = await api_follow.followTemplateList(per);
			// 	if (res.code == 1) {
			// 		this.followTemplateListData = res.data.list
			// 	} else {
			// 		this.$util.msg(res.message);
			// 		return;
			// 	}
			// },


			toUrl(url) {
				this.navTo(url);
			},
		}
	};
</script>

<style scoped lang="scss">
	.main {
		background: #FAFAFA;
		height: 100vh;
	}

	.bit {
		padding: 32rpx;
	}

	.but {
		width: 290rpx;
		height: 60rpx;
		background: #FFFFFF;
		border-radius: 50rpx 50rpx 50rpx 50rpx;
		padding: 0 30rpx;
	}

	.time {
		font-weight: 400;
		font-size: 28rpx;
		color: #7F7F7F;
	}

	.xltb {
		width: 32rpx;
		height: 32rpx;
	}

	.status {
		width: 200rpx;
		height: 40rpx;
		background: #1FA194;
		border-radius: 4rpx 4rpx 4rpx 4rpx;
		font-weight: 400;
		font-size: 24rpx;
		color: #FFFFFF;
	}

	.card-content {
		width: 686rpx;
		min-height: 160rpx;
		background: #FFFFFF;
		box-shadow: 0rpx 0rpx 8rpx -2rpx rgba(0, 0, 0, 0.04), 0rpx 0rpx 10rpx 0rpx rgba(0, 0, 0, 0.03), 0rpx 0rpx 20rpx 0rpx rgba(0, 0, 0, 0.02);
		border-radius: 20rpx 20rpx 20rpx 20rpx;
		padding: 32rpx;
		margin-bottom: 20rpx;
	}

	.clinic {
		font-weight: 400;
		font-size: 28rpx;
		color: rgba(0, 0, 0, 0.85);
	}


	.time {
		margin-top: 16rpx;
		font-weight: 400;
		font-size: 24rpx;
		color: rgba(0, 0, 0, 0.4);
	}

	.search-bar {
		margin: 20rpx 0;
		padding: 30rpx;
	}
</style>